/*
 * SubReader.java
 *January 6, 2014, Finals
 * Finals Completion Project
 * 
 * The following codes are the work of the IT.WORKS team in   
 * fulfillment of the requirement for Programming Applications
 * class code 9607. Copying of this work will result to 
 * serious consequences both to the IT.WORKs team and the plagiarizing 
 * party
 */

import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;

/**
 * This program reads subjects for the A+ Student Scheduler Application
 *
 * @author 2132446 Matib,Nicole
 ** @edited by 2132446
 *		-  added date line
 * @version 2.0.6
 */
public class SubReader {

    private String temp[];
    private Text words;
    public ArrayList<Text> coll;
    public int count = 0;

    public SubReader() {
        File file = new File("Subjects.txt");

        try {

            Scanner reader = new Scanner(file);
            coll = new ArrayList<Text>();
            while (reader.hasNext()) {
                temp = reader.nextLine().split(",");
                words = new Text(Integer.parseInt(temp[0]), temp[1], temp[2], Integer.parseInt(temp[3]), Integer.parseInt(temp[4]),
                        Integer.parseInt(temp[5]), Integer.parseInt(temp[6]), Integer.parseInt(temp[7]), temp[8], temp[9], temp[10]);
                coll.add(words);
                count = count + 1;
            }
        } catch (FileNotFoundException fnfe) {
        }

    }

    public int countRows() {
        return count;
    }

    public int readCode(int rows) {
        return coll.get(rows).getCode();
    }

    public String readDes(int rows) {
        return coll.get(rows).getDesTitle();
    }

    public int readUnit(int rows) {
        return coll.get(rows).getUnit();
    }

    public String readDays(int rows) {
        return coll.get(rows).getDays();
    }

    public String readCourse(int rows) {
        return coll.get(rows).getCourse();
    }

    public int readFromHour(int rows) {
        return coll.get(rows).getFromHour();
    }

    public int readFromMin(int rows) {
        return coll.get(rows).getFromMin();
    }

    public int readToHour(int rows) {
        return coll.get(rows).getToHour();
    }

    public int readToMin(int rows) {
        return coll.get(rows).getToMin();
    }

    public String readRoom(int rows) {
        return coll.get(rows).getRoom();
    }

    public String readInst(int rows) {
        return coll.get(rows).getInst();
    }
}